﻿using Sinc.ERP.Core.Enum;

namespace Sinc.ERP.Application.EventBus
{
    /// <summary>
    /// 产品实体卡事件订阅
    /// </summary>
    public class ProductCardSubscriber : IEventSubscriber, ISingleton, IDisposable
    {
        private ProductCardService ProductCardService => App.GetService<ProductCardService>();

        #region 补充实体卡验证码
        /// <summary>
        /// 补充实体卡验证码
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        [EventSubscribe(BusinessEventTypeEnum.ProductCard_FillIn)]
        public async Task FillIn(EventHandlerExecutingContext context)
        {
            var dict = context.Source.Payload as Dictionary<string, string> ?? throw Oops.Oh("参数错误");
            await this.ProductCardService.FillIn(dict);
        }
        #endregion

        #region 实现 IDisposable 接口
        public void Dispose() { }
        #endregion
    }
}
